package com.mob.tools.utils;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RoundRectShape;
import android.text.TextUtils;
import android.view.View;
import com.mob.tools.MobLog;
import com.mob.tools.log.NLog;
import com.mob.tools.network.HttpConnection;
import com.mob.tools.network.HttpResponseCallback;
import com.mob.tools.network.NetworkHelper;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class BitmapHelper
{
  public static Bitmap blur(Bitmap paramBitmap, int paramInt1, int paramInt2)
  {
    int i = paramBitmap.getWidth();
    int j = paramBitmap.getHeight();
    int k = (int)(0.5F + paramInt1 / paramInt2);
    Bitmap localBitmap = Bitmap.createBitmap((int)(0.5F + i / paramInt2), (int)(0.5F + j / paramInt2), Bitmap.Config.ARGB_8888);
    Canvas localCanvas = new Canvas(localBitmap);
    localCanvas.scale(1.0F / paramInt2, 1.0F / paramInt2);
    Paint localPaint = new Paint();
    localPaint.setFlags(2);
    localCanvas.drawBitmap(paramBitmap, 0.0F, 0.0F, localPaint);
    blur(localBitmap, k, true);
    return localBitmap;
  }

  private static Bitmap blur(Bitmap paramBitmap, int paramInt, boolean paramBoolean)
  {
    if (paramBoolean);
    for (Bitmap localBitmap = paramBitmap; paramInt < 1; localBitmap = paramBitmap.copy(paramBitmap.getConfig(), true))
      return null;
    int i = localBitmap.getWidth();
    int j = localBitmap.getHeight();
    int[] arrayOfInt1 = new int[i * j];
    localBitmap.getPixels(arrayOfInt1, 0, i, 0, 0, i, j);
    int k = i - 1;
    int m = j - 1;
    int n = i * j;
    int i1 = 1 + (paramInt + paramInt);
    int[] arrayOfInt2 = new int[n];
    int[] arrayOfInt3 = new int[n];
    int[] arrayOfInt4 = new int[n];
    int[] arrayOfInt5 = new int[Math.max(i, j)];
    int i2 = i1 + 1 >> 1;
    int i3 = i2 * i2;
    int[] arrayOfInt6 = new int[i3 * 256];
    for (int i4 = 0; ; i4++)
    {
      int i5 = i3 * 256;
      if (i4 >= i5)
        break;
      arrayOfInt6[i4] = (i4 / i3);
    }
    int i6 = 0;
    int i7 = 0;
    int[] arrayOfInt7 = { i1, 3 };
    int[][] arrayOfInt = (int[][])Array.newInstance(Integer.TYPE, arrayOfInt7);
    int i8 = paramInt + 1;
    for (int i9 = 0; i9 < j; i9++)
    {
      int i37 = 0;
      int i38 = 0;
      int i39 = 0;
      int i40 = 0;
      int i41 = 0;
      int i42 = 0;
      int i43 = 0;
      int i44 = 0;
      int i45 = 0;
      int i46 = -paramInt;
      if (i46 <= paramInt)
      {
        int i59 = arrayOfInt1[(i6 + Math.min(k, Math.max(i46, 0)))];
        int[] arrayOfInt13 = arrayOfInt[(i46 + paramInt)];
        arrayOfInt13[0] = ((0xFF0000 & i59) >> 16);
        arrayOfInt13[1] = ((0xFF00 & i59) >> 8);
        arrayOfInt13[2] = (i59 & 0xFF);
        int i60 = i8 - Math.abs(i46);
        i39 += i60 * arrayOfInt13[0];
        i38 += i60 * arrayOfInt13[1];
        i37 += i60 * arrayOfInt13[2];
        if (i46 > 0)
        {
          i45 += arrayOfInt13[0];
          i44 += arrayOfInt13[1];
          i43 += arrayOfInt13[2];
        }
        while (true)
        {
          i46++;
          break;
          i42 += arrayOfInt13[0];
          i41 += arrayOfInt13[1];
          i40 += arrayOfInt13[2];
        }
      }
      int i47 = paramInt;
      for (int i48 = 0; i48 < i; i48++)
      {
        arrayOfInt2[i6] = arrayOfInt6[i39];
        arrayOfInt3[i6] = arrayOfInt6[i38];
        arrayOfInt4[i6] = arrayOfInt6[i37];
        int i49 = i39 - i42;
        int i50 = i38 - i41;
        int i51 = i37 - i40;
        int[] arrayOfInt11 = arrayOfInt[((i1 + (i47 - paramInt)) % i1)];
        int i52 = i42 - arrayOfInt11[0];
        int i53 = i41 - arrayOfInt11[1];
        int i54 = i40 - arrayOfInt11[2];
        if (i9 == 0)
          arrayOfInt5[i48] = Math.min(1 + (i48 + paramInt), k);
        int i55 = arrayOfInt1[(i7 + arrayOfInt5[i48])];
        arrayOfInt11[0] = ((0xFF0000 & i55) >> 16);
        arrayOfInt11[1] = ((0xFF00 & i55) >> 8);
        arrayOfInt11[2] = (i55 & 0xFF);
        int i56 = i45 + arrayOfInt11[0];
        int i57 = i44 + arrayOfInt11[1];
        int i58 = i43 + arrayOfInt11[2];
        i39 = i49 + i56;
        i38 = i50 + i57;
        i37 = i51 + i58;
        i47 = (i47 + 1) % i1;
        int[] arrayOfInt12 = arrayOfInt[(i47 % i1)];
        i42 = i52 + arrayOfInt12[0];
        i41 = i53 + arrayOfInt12[1];
        i40 = i54 + arrayOfInt12[2];
        i45 = i56 - arrayOfInt12[0];
        i44 = i57 - arrayOfInt12[1];
        i43 = i58 - arrayOfInt12[2];
        i6++;
      }
      i7 += i;
    }
    for (int i10 = 0; i10 < i; i10++)
    {
      int i11 = 0;
      int i12 = 0;
      int i13 = 0;
      int i14 = 0;
      int i15 = 0;
      int i16 = 0;
      int i17 = 0;
      int i18 = 0;
      int i19 = 0;
      int i20 = i * -paramInt;
      int i21 = -paramInt;
      if (i21 <= paramInt)
      {
        int i35 = i10 + Math.max(0, i20);
        int[] arrayOfInt10 = arrayOfInt[(i21 + paramInt)];
        arrayOfInt10[0] = arrayOfInt2[i35];
        arrayOfInt10[1] = arrayOfInt3[i35];
        arrayOfInt10[2] = arrayOfInt4[i35];
        int i36 = i8 - Math.abs(i21);
        i13 += i36 * arrayOfInt2[i35];
        i12 += i36 * arrayOfInt3[i35];
        i11 += i36 * arrayOfInt4[i35];
        if (i21 > 0)
        {
          i19 += arrayOfInt10[0];
          i18 += arrayOfInt10[1];
          i17 += arrayOfInt10[2];
        }
        while (true)
        {
          if (i21 < m)
            i20 += i;
          i21++;
          break;
          i16 += arrayOfInt10[0];
          i15 += arrayOfInt10[1];
          i14 += arrayOfInt10[2];
        }
      }
      int i22 = i10;
      int i23 = paramInt;
      for (int i24 = 0; i24 < j; i24++)
      {
        arrayOfInt1[i22] = (0xFF000000 & arrayOfInt1[i22] | arrayOfInt6[i13] << 16 | arrayOfInt6[i12] << 8 | arrayOfInt6[i11]);
        int i25 = i13 - i16;
        int i26 = i12 - i15;
        int i27 = i11 - i14;
        int[] arrayOfInt8 = arrayOfInt[((i1 + (i23 - paramInt)) % i1)];
        int i28 = i16 - arrayOfInt8[0];
        int i29 = i15 - arrayOfInt8[1];
        int i30 = i14 - arrayOfInt8[2];
        if (i10 == 0)
          arrayOfInt5[i24] = (i * Math.min(i24 + i8, m));
        int i31 = i10 + arrayOfInt5[i24];
        arrayOfInt8[0] = arrayOfInt2[i31];
        arrayOfInt8[1] = arrayOfInt3[i31];
        arrayOfInt8[2] = arrayOfInt4[i31];
        int i32 = i19 + arrayOfInt8[0];
        int i33 = i18 + arrayOfInt8[1];
        int i34 = i17 + arrayOfInt8[2];
        i13 = i25 + i32;
        i12 = i26 + i33;
        i11 = i27 + i34;
        i23 = (i23 + 1) % i1;
        int[] arrayOfInt9 = arrayOfInt[i23];
        i16 = i28 + arrayOfInt9[0];
        i15 = i29 + arrayOfInt9[1];
        i14 = i30 + arrayOfInt9[2];
        i19 = i32 - arrayOfInt9[0];
        i18 = i33 - arrayOfInt9[1];
        i17 = i34 - arrayOfInt9[2];
        i22 += i;
      }
    }
    localBitmap.setPixels(arrayOfInt1, 0, i, 0, 0, i, j);
    return localBitmap;
  }

  private static boolean bytesStartWith(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2)
  {
    if (paramArrayOfByte1 == paramArrayOfByte2);
    while (true)
    {
      return true;
      if ((paramArrayOfByte1 == null) || (paramArrayOfByte2 == null))
        return false;
      if (paramArrayOfByte1.length < paramArrayOfByte2.length)
        return false;
      for (int i = 0; i < paramArrayOfByte2.length; i++)
        if (paramArrayOfByte1[i] != paramArrayOfByte2[i])
          return false;
    }
  }

  public static Bitmap captureView(View paramView, int paramInt1, int paramInt2)
    throws Throwable
  {
    Bitmap localBitmap = Bitmap.createBitmap(paramInt1, paramInt2, Bitmap.Config.ARGB_8888);
    paramView.draw(new Canvas(localBitmap));
    return localBitmap;
  }

  public static Bitmap cropBitmap(Bitmap paramBitmap, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
    throws Throwable
  {
    int i = paramBitmap.getWidth() - paramInt1 - paramInt3;
    int j = paramBitmap.getHeight() - paramInt2 - paramInt4;
    if ((i == paramBitmap.getWidth()) && (j == paramBitmap.getHeight()))
      return paramBitmap;
    Bitmap localBitmap = Bitmap.createBitmap(i, j, Bitmap.Config.ARGB_8888);
    Canvas localCanvas = new Canvas(localBitmap);
    Paint localPaint = new Paint();
    localCanvas.drawBitmap(paramBitmap, -paramInt1, -paramInt2, localPaint);
    return localBitmap;
  }

  public static String downloadBitmap(Context paramContext, String paramString)
    throws Throwable
  {
    final String str = R.getCachePath(paramContext, "images");
    File localFile = new File(str, Data.MD5(paramString));
    if (localFile.exists())
      return localFile.getAbsolutePath();
    final HashMap localHashMap = new HashMap();
    new NetworkHelper().rawGet(paramString, new HttpResponseCallback()
    {
      public void onResponse(HttpConnection paramAnonymousHttpConnection)
        throws Throwable
      {
        int i = paramAnonymousHttpConnection.getResponseCode();
        if (i == 200)
        {
          String str2 = BitmapHelper.getFileName(paramAnonymousHttpConnection, this.val$imageUrl);
          File localFile = new File(str, str2);
          if (localFile.exists())
          {
            localHashMap.put("bitmap", localFile.getAbsolutePath());
            return;
          }
          if (!localFile.getParentFile().exists())
            localFile.getParentFile().mkdirs();
          if (localFile.exists())
            localFile.delete();
          while (true)
          {
            Bitmap localBitmap;
            FileOutputStream localFileOutputStream;
            try
            {
              localBitmap = BitmapHelper.getBitmap(new FilterInputStream(paramAnonymousHttpConnection.getInputStream())
              {
                public long skip(long paramAnonymous2Long)
                  throws IOException
                {
                  long l2;
                  for (long l1 = 0L; ; l1 += l2)
                    if (l1 < paramAnonymous2Long)
                    {
                      l2 = this.in.skip(paramAnonymous2Long - l1);
                      if (l2 != 0L);
                    }
                    else
                    {
                      return l1;
                    }
                }
              }
              , 1);
              if ((localBitmap == null) || (localBitmap.isRecycled()))
                break;
              localFileOutputStream = new FileOutputStream(localFile);
              if ((str2.toLowerCase().endsWith(".gif")) || (str2.toLowerCase().endsWith(".png")))
              {
                localBitmap.compress(Bitmap.CompressFormat.PNG, 100, localFileOutputStream);
                localFileOutputStream.flush();
                localFileOutputStream.close();
                localHashMap.put("bitmap", localFile.getAbsolutePath());
                return;
              }
            }
            catch (Throwable localThrowable)
            {
              if (localFile.exists())
                localFile.delete();
              throw localThrowable;
            }
            localBitmap.compress(Bitmap.CompressFormat.JPEG, 80, localFileOutputStream);
          }
        }
        StringBuilder localStringBuilder = new StringBuilder();
        BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(paramAnonymousHttpConnection.getErrorStream(), Charset.forName("utf-8")));
        for (String str1 = localBufferedReader.readLine(); str1 != null; str1 = localBufferedReader.readLine())
        {
          if (localStringBuilder.length() > 0)
            localStringBuilder.append('\n');
          localStringBuilder.append(str1);
        }
        localBufferedReader.close();
        HashMap localHashMap = new HashMap();
        localHashMap.put("error", localStringBuilder.toString());
        localHashMap.put("status", Integer.valueOf(i));
        throw new Throwable(new Hashon().fromHashMap(localHashMap));
      }
    }
    , null);
    return (String)localHashMap.get("bitmap");
  }

  public static int[] fixRect(int[] paramArrayOfInt1, int[] paramArrayOfInt2)
  {
    int[] arrayOfInt = new int[2];
    if (paramArrayOfInt1[0] / paramArrayOfInt1[1] > paramArrayOfInt2[0] / paramArrayOfInt2[1])
    {
      arrayOfInt[0] = paramArrayOfInt2[0];
      arrayOfInt[1] = ((int)(0.5F + paramArrayOfInt1[1] * paramArrayOfInt2[0] / paramArrayOfInt1[0]));
      return arrayOfInt;
    }
    arrayOfInt[1] = paramArrayOfInt2[1];
    arrayOfInt[0] = ((int)(0.5F + paramArrayOfInt1[0] * paramArrayOfInt2[1] / paramArrayOfInt1[1]));
    return arrayOfInt;
  }

  public static int[] fixRect_2(int[] paramArrayOfInt1, int[] paramArrayOfInt2)
  {
    int[] arrayOfInt = new int[2];
    if (paramArrayOfInt1[0] / paramArrayOfInt1[1] > paramArrayOfInt2[0] / paramArrayOfInt2[1])
    {
      arrayOfInt[1] = paramArrayOfInt2[1];
      arrayOfInt[0] = ((int)(0.5F + paramArrayOfInt1[0] * paramArrayOfInt2[1] / paramArrayOfInt1[1]));
      return arrayOfInt;
    }
    arrayOfInt[0] = paramArrayOfInt2[0];
    arrayOfInt[1] = ((int)(0.5F + paramArrayOfInt1[1] * paramArrayOfInt2[0] / paramArrayOfInt1[0]));
    return arrayOfInt;
  }

  public static Bitmap getBitmap(Context paramContext, String paramString)
    throws Throwable
  {
    return getBitmap(downloadBitmap(paramContext, paramString));
  }

  public static Bitmap getBitmap(File paramFile, int paramInt)
    throws Throwable
  {
    if ((paramFile == null) || (!paramFile.exists()))
      return null;
    FileInputStream localFileInputStream = new FileInputStream(paramFile);
    Bitmap localBitmap = getBitmap(localFileInputStream, paramInt);
    localFileInputStream.close();
    return localBitmap;
  }

  public static Bitmap getBitmap(InputStream paramInputStream, int paramInt)
  {
    if (paramInputStream == null)
      return null;
    BitmapFactory.Options localOptions = new BitmapFactory.Options();
    localOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
    localOptions.inPurgeable = true;
    localOptions.inInputShareable = true;
    localOptions.inSampleSize = paramInt;
    return BitmapFactory.decodeStream(paramInputStream, null, localOptions);
  }

  public static Bitmap getBitmap(String paramString)
    throws Throwable
  {
    return getBitmap(paramString, 1);
  }

  public static Bitmap getBitmap(String paramString, int paramInt)
    throws Throwable
  {
    if (TextUtils.isEmpty(paramString))
      return null;
    return getBitmap(new File(paramString), paramInt);
  }

  public static Bitmap.CompressFormat getBmpFormat(String paramString)
  {
    String str1 = paramString.toLowerCase();
    if ((str1.endsWith("png")) || (str1.endsWith("gif")))
      return Bitmap.CompressFormat.PNG;
    if ((str1.endsWith("jpg")) || (str1.endsWith("jpeg")) || (str1.endsWith("bmp")) || (str1.endsWith("tif")))
      return Bitmap.CompressFormat.JPEG;
    String str2 = getMime(paramString);
    if ((str2.endsWith("png")) || (str2.endsWith("gif")))
      return Bitmap.CompressFormat.PNG;
    return Bitmap.CompressFormat.JPEG;
  }

  public static Bitmap.CompressFormat getBmpFormat(byte[] paramArrayOfByte)
  {
    String str = getMime(paramArrayOfByte);
    Bitmap.CompressFormat localCompressFormat = Bitmap.CompressFormat.JPEG;
    if ((str != null) && ((str.endsWith("png")) || (str.endsWith("gif"))))
      localCompressFormat = Bitmap.CompressFormat.PNG;
    return localCompressFormat;
  }

  private static String getFileName(HttpConnection paramHttpConnection, String paramString)
    throws Throwable
  {
    Map localMap = paramHttpConnection.getHeaderFields();
    String str1 = null;
    if (localMap != null)
    {
      List localList2 = (List)localMap.get("Content-Disposition");
      str1 = null;
      if (localList2 != null)
      {
        int k = localList2.size();
        str1 = null;
        if (k > 0)
          for (String str6 : ((String)localList2.get(0)).split(";"))
            if (str6.trim().startsWith("filename"))
            {
              str1 = str6.split("=")[1];
              if ((str1.startsWith("\"")) && (str1.endsWith("\"")))
                str1 = str1.substring(1, -1 + str1.length());
            }
      }
    }
    String str2;
    String str3;
    if (str1 == null)
    {
      str1 = Data.MD5(paramString);
      if (localMap != null)
      {
        List localList1 = (List)localMap.get("Content-Type");
        if ((localList1 != null) && (localList1.size() > 0))
        {
          str2 = (String)localList1.get(0);
          if (str2 != null)
            break label289;
          str3 = "";
          if (!str3.startsWith("image/"))
            break label299;
          String str5 = str3.substring("image/".length());
          StringBuilder localStringBuilder = new StringBuilder().append(str1).append(".");
          if ("jpeg".equals(str5))
            str5 = "jpg";
          str1 = str5;
        }
      }
    }
    label289: label299: String str4;
    int j;
    do
    {
      do
      {
        return str1;
        str3 = str2.trim();
        break;
        int i = paramString.lastIndexOf('/');
        str4 = null;
        if (i > 0)
          str4 = paramString.substring(i + 1);
      }
      while ((str4 == null) || (str4.length() <= 0));
      j = str4.lastIndexOf('.');
    }
    while ((j <= 0) || (str4.length() - j >= 10));
    return str1 + str4.substring(j);
  }

  private static String getMime(String paramString)
  {
    try
    {
      FileInputStream localFileInputStream = new FileInputStream(paramString);
      byte[] arrayOfByte = new byte[8];
      localFileInputStream.read(arrayOfByte);
      localFileInputStream.close();
      String str = getMime(arrayOfByte);
      return str;
    }
    catch (Exception localException)
    {
      MobLog.getInstance().w(localException);
    }
    return null;
  }

  private static String getMime(byte[] paramArrayOfByte)
  {
    byte[] arrayOfByte1 = { -1, -40, -1, -32 };
    byte[] arrayOfByte2 = { -1, -40, -1, -31 };
    if ((bytesStartWith(paramArrayOfByte, arrayOfByte1)) || (bytesStartWith(paramArrayOfByte, arrayOfByte2)))
      return "jpg";
    if (bytesStartWith(paramArrayOfByte, new byte[] { -119, 80, 78, 71 }))
      return "png";
    if (bytesStartWith(paramArrayOfByte, "GIF".getBytes()))
      return "gif";
    if (bytesStartWith(paramArrayOfByte, "BM".getBytes()))
      return "bmp";
    byte[] arrayOfByte3 = { 73, 73, 42 };
    byte[] arrayOfByte4 = { 77, 77, 42 };
    if ((bytesStartWith(paramArrayOfByte, arrayOfByte3)) || (bytesStartWith(paramArrayOfByte, arrayOfByte4)))
      return "tif";
    return null;
  }

  public static boolean isBlackBitmap(Bitmap paramBitmap)
    throws Throwable
  {
    boolean bool;
    if ((paramBitmap == null) || (paramBitmap.isRecycled()))
    {
      bool = true;
      return bool;
    }
    int[] arrayOfInt = new int[paramBitmap.getWidth() * paramBitmap.getHeight()];
    paramBitmap.getPixels(arrayOfInt, 0, paramBitmap.getWidth(), 0, 0, paramBitmap.getWidth(), paramBitmap.getHeight());
    for (int i = 0; ; i++)
    {
      int j = arrayOfInt.length;
      int k = 0;
      if (i < j)
      {
        if ((0xFFFFFF & arrayOfInt[i]) != 0)
          k = 1;
      }
      else
      {
        bool = false;
        if (k != 0)
          break;
        return true;
      }
    }
  }

  public static int mixAlpha(int paramInt1, int paramInt2)
  {
    int i = paramInt1 >>> 24;
    int j = (0xFF0000 & paramInt1) >>> 16;
    int k = (0xFF00 & paramInt1) >>> 8;
    int m = paramInt1 & 0xFF;
    int n = (0xFF0000 & paramInt2) >>> 16;
    int i1 = (0xFF00 & paramInt2) >>> 8;
    int i2 = paramInt2 & 0xFF;
    return 0xFF000000 | (i * j + n * (255 - i)) / 255 << 16 | (i * k + i1 * (255 - i)) / 255 << 8 | (i * m + i2 * (255 - i)) / 255;
  }

  public static Bitmap roundBitmap(Bitmap paramBitmap, int paramInt1, int paramInt2, float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4)
    throws Throwable
  {
    int i = paramBitmap.getWidth();
    int j = paramBitmap.getHeight();
    Rect localRect1 = new Rect(0, 0, i, j);
    if ((i != paramInt1) || (j != paramInt2));
    for (Bitmap localBitmap = Bitmap.createBitmap(paramInt1, paramInt2, Bitmap.Config.ARGB_8888); ; localBitmap = Bitmap.createBitmap(paramBitmap.getWidth(), paramBitmap.getHeight(), Bitmap.Config.ARGB_8888))
    {
      Canvas localCanvas = new Canvas(localBitmap);
      Paint localPaint = new Paint();
      Rect localRect2 = new Rect(0, 0, paramInt1, paramInt2);
      localPaint.setAntiAlias(true);
      localCanvas.drawARGB(0, 0, 0, 0);
      localPaint.setColor(-12434878);
      float[] arrayOfFloat = { paramFloat1, paramFloat1, paramFloat2, paramFloat2, paramFloat3, paramFloat3, paramFloat4, paramFloat4 };
      ShapeDrawable localShapeDrawable = new ShapeDrawable(new RoundRectShape(arrayOfFloat, new RectF(0.0F, 0.0F, 0.0F, 0.0F), arrayOfFloat));
      localShapeDrawable.setBounds(localRect2);
      localShapeDrawable.draw(localCanvas);
      localPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
      localCanvas.drawBitmap(paramBitmap, localRect1, localRect2, localPaint);
      return localBitmap;
    }
  }

  public static String saveBitmap(Context paramContext, Bitmap paramBitmap)
    throws Throwable
  {
    return saveBitmap(paramContext, paramBitmap, Bitmap.CompressFormat.JPEG, 80);
  }

  public static String saveBitmap(Context paramContext, Bitmap paramBitmap, Bitmap.CompressFormat paramCompressFormat, int paramInt)
    throws Throwable
  {
    String str1 = R.getCachePath(paramContext, "images");
    String str2 = ".jpg";
    if (paramCompressFormat == Bitmap.CompressFormat.PNG)
      str2 = ".png";
    File localFile = new File(str1, String.valueOf(System.currentTimeMillis()) + str2);
    FileOutputStream localFileOutputStream = new FileOutputStream(localFile);
    paramBitmap.compress(paramCompressFormat, paramInt, localFileOutputStream);
    localFileOutputStream.flush();
    localFileOutputStream.close();
    return localFile.getAbsolutePath();
  }

  public static String saveViewToImage(View paramView)
    throws Throwable
  {
    if (paramView == null);
    int i;
    int j;
    do
    {
      return null;
      i = paramView.getWidth();
      j = paramView.getHeight();
    }
    while ((i <= 0) || (j <= 0));
    return saveViewToImage(paramView, i, j);
  }

  public static String saveViewToImage(View paramView, int paramInt1, int paramInt2)
    throws Throwable
  {
    Bitmap localBitmap = captureView(paramView, paramInt1, paramInt2);
    if ((localBitmap == null) || (localBitmap.isRecycled()))
      return null;
    File localFile = new File(R.getCachePath(paramView.getContext(), "screenshot"), String.valueOf(System.currentTimeMillis()) + ".jpg");
    FileOutputStream localFileOutputStream = new FileOutputStream(localFile);
    localBitmap.compress(Bitmap.CompressFormat.JPEG, 100, localFileOutputStream);
    localFileOutputStream.flush();
    localFileOutputStream.close();
    return localFile.getAbsolutePath();
  }

  public static Bitmap scaleBitmapByHeight(Context paramContext, int paramInt1, int paramInt2)
    throws Throwable
  {
    Bitmap localBitmap1 = BitmapFactory.decodeResource(paramContext.getResources(), paramInt1);
    if (paramInt2 != localBitmap1.getHeight());
    for (int i = 1; ; i = 0)
    {
      Bitmap localBitmap2 = scaleBitmapByHeight(localBitmap1, paramInt2);
      if (i != 0)
        localBitmap1.recycle();
      return localBitmap2;
    }
  }

  public static Bitmap scaleBitmapByHeight(Bitmap paramBitmap, int paramInt)
    throws Throwable
  {
    return Bitmap.createScaledBitmap(paramBitmap, paramInt * paramBitmap.getWidth() / paramBitmap.getHeight(), paramInt, true);
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.mob.tools.utils.BitmapHelper
 * JD-Core Version:    0.6.2
 */